package com.mzj.saas.mservice.area.repository;

import com.mzj.saas.mservice.area.entity.AreaSearchLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

public interface AreaSearchLogRepository extends PagingAndSortingRepository<AreaSearchLog, Long>, JpaSpecificationExecutor<AreaSearchLog> {

    /**
     * 城市搜索记录VO
     */
    public interface AreaSearchLogCountVo {
        String getName();
        Integer getCount();
    }

    @Query(value = "SELECT COUNT(1) as count , name FROM sys_area_search_log GROUP BY NAME ORDER BY count DESC LIMIT 4 ", nativeQuery = true)
    List<AreaSearchLogCountVo> findGroupByName();
}
